import { Injectable, Injector } from '@angular/core';
import { Constant, ServiceResult } from '@core/constant';
import {_HttpClient, SettingsService} from '@delon/theme';
import { MyHttpClient } from '../MyHttpClient';

@Injectable()
export class ProductService {
  get cnt(): Constant {
    return this.injector.get(Constant);
  }
  constructor(
    private injector: Injector,
    private http: _HttpClient,
    private myHttp: MyHttpClient,
    public setting: SettingsService,

  ) {}

  /**
   * 分页获取商品
   */
  list(): string {
    return `${this.cnt.baseUrl}/rest/fxjOrderMainController/list/`+this.setting.user.username;
  }

  listfxjpoprice(orderNo): string {
    return `${this.cnt.baseUrl}/rest/fxjOrderMainController/listdetail1/`+orderNo;
  }

  createfxjpoprice(prods) {
    return this.http.post(
      `${this.cnt.baseUrl}/rest/fxjOrderMainController/cre/1`,
      prods,
    );
  }
  //删除
  delid(id,deltype) {
    return this.http.get(`${this.cnt.baseUrl}/rest/fxjOrderMainController/del/`+id+"?deltype="+deltype);
  }
  /**
   * 分页获取商品
   */
  logurl(): string {
    return `${this.cnt.baseUrl}/rest/fxjOrderMainController/loglist/`;
  }

  rmurl(): string {
    return `${this.cnt.baseUrl}/rest/fxjOrderMainController/rmlist/`;
  }

  list2(): string {
    return `${this.cnt.baseUrl}/api/sms/prod/product/page2`;
  }
  /**
   * 上传图片
   */
  uploadUrl() {
    return `${this.cnt.baseUrl}/rest/base/upload`;
  }

  /**
   * 文件管理
   */
  uploadfileUrl() {
    return `${this.cnt.baseUrl}/rest/base/uploadfile`;
  }
  /**
   * 上传图片
   */
  uploadsbUrl() {
    return `${this.cnt.baseUrl}/rest/base/uploadsb`;
  }
  /**
   * 添加商品
   * @param prods
   */
  addPro(fxjOrderMainPage) {
    return this.http.post(
      `${this.cnt.baseUrl}/rest/fxjOrderMainController/`+this.setting.user.username,
      fxjOrderMainPage,
    );
  }

  gencon(orderNo,conHead) {
    return this.http.post(
      `${this.cnt.baseUrl}/rest/base/getcon/`+orderNo,
      conHead,
    );
  }


  /**
   * 修改商品
   * @param product
   */
  editPro(product) {
    return this.http.put(
      `${this.cnt.baseUrl}/rest/fxjOrderMainController/${product.id}`,
      product,
    );
  }

  /**
   * 修改商品
   * @param product
   */
  stopmq(mqlog) {
    return this.http.put(
      `${this.cnt.baseUrl}/rest/fxjMqLogController/stop`,
      mqlog,
    );
  }
  /**
   * 修改商品
   * @param product
   */
  rmquery(fkname,fkinput) {
    return this.http.post(
      `${this.cnt.baseUrl}/rest/fk/${fkname}`,
      fkinput,
    );
  }
  getProduct(productId) {
    return this.http.get(
      `${this.cnt.baseUrl}/rest/fxjOrderMainController/${productId}`,
    );
  }

  getfileList(productId,attaType) {
    return this.http.get(
      `${this.cnt.baseUrl}/rest/fxjOrderMainController/filelist/${productId}`+"?attaType="+attaType,
    );
  }
  getbihome(bitype) {
    return this.http.get(
      `${this.cnt.baseUrl}/rest/basebi/getbi/`+this.setting.user.username+"?pageNumber=1&pageSize=9999&bitype="+bitype,
    );
  }
  getbi(bitype) {
    return this.http.get(
      `${this.cnt.baseUrl}/rest/basebi/getbi/`+this.setting.user.username+"?bitype="+bitype,
    );
  }

}
